<?php
namespace Home\Controller;
use Think\Controller;
class IndexController extends Controller {
    
    public function Index(){
    	writeLog("Index");
    	$this->setBegin();
    	$this->redirect("Home/Index/ajaxIndex");
    }
    public function ajaxIndex(){
    	$this->assign("startFun","interviewPanel()");
    	$this->display('index_1');
    }
    public function ajaxWorker(){
    	$ajaxInit = "workerPanel()";
    	$this->assign("startFun",$ajaxInit);
    	$this->display('index_1');
    }
    //初始化
    public function setBegin(){
    	session('iry_itwWpage',1);
    	session('iry_itwHpage',1);
    }
    //权限验证
    public function valiAtoy(){
    	//Ip权限
    	$ip = get_client_ip();
    	$atoy_ip = C('atoy_ip');
    	if(in_array($ip,$atoy_ip)) 
    		$this->error('权限认证失败!请联系管理员!','http://10.0.1.43');
    	
    }
    //文件下载
    public function downLoad(){
    	writeLog("downloadfile,".$_GET['filename']);
    	$file_name=$_GET['filename'];
    	if(!$file_name) $this->error('文件错误!');
    	
    	if(!file_exists($file_name)){
    		echo $file_name;
    		return ;
    	}
    	$file_size=filesize($file_name);
    	$file_handle=fopen($file_name,'r');
    	
    	header("Content-type:"."application/gz");
    	header("Content-Disposition:attachment;filename=".basename($file_name));
    	header("Cache-control:public");
    	header("Pragma:public");
    	header("Content-Length:".$file_size);
    	
    	ob_clean();                                          //关闭缓冲
    	flush();
    	
    	$buffer=1024;
    	$file_count=0;
    	while(!feof($file_handle)&&$file_count<$file_size){
    		$realfile=fread($file_handle,$buffer);
    		$file_count+=$buffer;
    		echo $realfile;
    	}
    	fclose($file_handle);
    }
}